package com.example.myapplication.fragment;


import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;

import androidx.fragment.app.Fragment;

import com.bumptech.glide.Glide;
import com.example.mvp.mvp.view.BaseFragment;
import com.example.myapplication.R;
import com.example.myapplication.a_mvp.presenter.MyPresenter;
import com.example.myapplication.b_entity.ComEntity;
import com.flyco.tablayout.CommonTabLayout;
import com.flyco.tablayout.listener.CustomTabEntity;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.tabs.TabLayout;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshHeader;
import com.scwang.smartrefresh.layout.listener.SimpleMultiPurposeListener;

import java.util.ArrayList;

/**
 * A simple {@link Fragment} subclass.
 */
public class BlankFragment4 extends BaseFragment<MyPresenter> {


    private ImageView mainImg;
    private SmartRefreshLayout mainRefresh;
    private AppBarLayout mainApp;
    private TabLayout mainTab;
    private ImageView imageImg;
    private CommonTabLayout mainCom;
    private ArrayList<CustomTabEntity> tabEntitys  = new ArrayList<>();

    @Override
    public int findlayout() {
        return R.layout.fragment_blank_fragment4;
    }

    @Override
    public void initView() {

        mainImg = (ImageView) findViewById(R.id.main_img);
        mainRefresh = (SmartRefreshLayout) findViewById(R.id.main_refresh);
        mainApp = (AppBarLayout) findViewById(R.id.main_app);

        View inflate = LayoutInflater.from(getContext()).inflate(R.layout.fragment_image, null);
        ImageView viewById = inflate.findViewById(R.id.image_img);
        viewById.setImageResource(R.drawable.ic_launcher_background);
        Glide.with(getContext()).load("http://5b0988e595225.cdn.sohucs.com/images/20180618/5a915fae934a4b11b1cdbc896d2598de.jpeg").into(mainImg);
        imageImg = (ImageView) findViewById(R.id.image_img);
        mainCom = (CommonTabLayout) findViewById(R.id.main_com);
    }

    @Override
    public void initData() {
        mainRefresh.setOnMultiPurposeListener(new SimpleMultiPurposeListener() {
            @Override
            public void onHeaderMoving(RefreshHeader header, boolean isDragging, float percent, int offset, int headerHeight, int maxDragHeight) {
                super.onHeaderMoving(header, isDragging, percent, offset, headerHeight, maxDragHeight);
                mainImg.setScaleX(1 + (float) (percent * 0.3));
                mainImg.setScaleY(1 + (float) (percent * 0.3));
            }
        });
        tabEntitys.add(new ComEntity("隐私",0,0));
        tabEntitys.add(new ComEntity("作品",0,0));
        tabEntitys.add(new ComEntity("喜欢",0,0));
        tabEntitys.add(new ComEntity("他的",0,0));
        tabEntitys.add(new ComEntity("拉黑",0,0));
        mainCom.setTabData(tabEntitys);



    }

}
